from autotest.framework.base_page import BasePage
from selenium.webdriver.common.by import By
from autotest.logs.logger import Logger

logger = Logger(logger="login_page").getlog()

class Login(BasePage):
    #定位器页面要用的元素统一获取 应该做个判断是否获取到标签的异常返回给日志 方便后续页面更改
    select_box=(By.XPATH, '//*[@id="app"]/div[1]/div[1]/div[2]/div/div/div/div[2]/form/div[1]/div/div/div/div/div/div')
    username_input=(By.ID,'form_item_account')
    password_input=(By.ID,'form_item_password')
    check_password_input = (By.XPATH,'//*[@id="app"]/div[1]/div[1]/div[2]/div/div/div/div[2]/form/div[3]/div/div/div/div/span/span[2]/span')
    yanzhenma_btn=(By.XPATH,'//*[@id="app"]/div[1]/div[1]/div[2]/div/div/div/div[2]/form/div[4]/div/div/div/div/span/a[1]')
    phonelogin_btn=(By.XPATH,'//*[@id="app"]/div[1]/div[1]/div[2]/div/div/div/div[2]/form/div[4]/div/div/div/div/span/a[2]')
    wangji_password_btn=(By.XPATH,'//*[@id="app"]/div[1]/div[1]/div[2]/div/div/div/div[2]/form/div[4]/div/div/div/div/a')
    login_btn=(By.XPATH,'//*[@id="app"]/div[1]/div[1]/div[2]/div/div/div/div[2]/form/div[5]/div/div/div/div/button')
#输入账号
    def value_username_input(self,text):
        self.wait(self.username_input,5)
        self.send_keys(self.username_input,text)
#输入密码
    def value_password_input(self,text):
        self.wait(self.password_input,5)
        self.send_keys(self.password_input,text)
#点击登录按钮
    def submit_btn(self):
        self.click(self.login_btn)
        logger.info("登录中，查看结果")
        self.sleep(2)
#验证码按钮
    def yanzhenma_click(self):
        self.click(self.yanzhenma_btn)
        logger.info("点击了验证码登录")
        self.sleep(2)
#手机号登录按钮
    def phonelogin_click(self):
        self.click(self.phonelogin_btn)
        logger.info("点击了手机号登录")
        self.sleep(2)
#查看密码
    def check_password_click(self):
        self.click(self.check_password_input)
        logger.info("点击了显示密码，要截图看看效果")
        self.sleep(2)
#选择其他产品
    def select_product(self):
        self.click(self.select_box)
        logger.info("选择产品,还没有思路")
        self.sleep(2)